class Solution {
public:
    int takeAttendance(vector<int>& records) {
        int left=0;
        int right=records.size();
        while(left<right)
        {
            int mid=left+(right-left)/2;
            if(records[mid]>mid)
            {
                right=mid;
            }
            if(records[mid]==mid)
            {
                left=mid+1;
            }
        }
        return right;
    }
};
